package com.pingan.haofang.searchcloud.common.auth;

import com.pingan.haofang.searchcloud.index.service.IndexService;
import com.pingan.haofang.searchcloud.indexdatasource.service.IndexDatasourceService;
import com.pingan.haofang.searchcloud.user.service.SearchProjectService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 初始化校验器
 *
 * @author zhangbi
 * @date 2017/6/17
 * @since 1.0.0
 */
@Component
public class AuthValidatorInit implements ApplicationRunner {

    private static final Logger LOGGER = LoggerFactory.getLogger(AuthValidatorInit.class);

    @Autowired
    private SearchProjectService searchProjectService;

    @Autowired
    private IndexService indexService;

    @Autowired
    private IndexDatasourceService indexDatasourceService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        DataAuthValidator.setIndexService(indexService);
        DataAuthValidator.setSearchProjectService(searchProjectService);
        DataAuthValidator.setIndexDatasourceService(indexDatasourceService);
        LOGGER.info("DataAuthValidator init success");
    }
}
